import {listRole} from '_api/system/role'

export default {
  namespaced: true,
  state: {
    roleList: []
  },
  mutations: {
    setRoleList(state, roleList) {
      state.roleList = roleList
    }
  },
  actions: {
    listRole({state, commit}) {
      return new Promise((resolve, reject) => {
        listRole().then(res => {
          if (res) {
            let data = res.data;
            commit('setRoleList', data)
            resolve(data)
          }
        }).catch(err => {
          reject(err)
        })
      })
    }
  }
}
